<script setup>
import { ref } from 'vue';

const notificationSettings = ref({
  email: true,
  sms: false,
  push: true
});

const handleSaveSettings = () => {
  // 这里实现通知设置保存逻辑
  console.log('保存通知设置：', notificationSettings.value);
  // 实际项目中应该调用API
};
</script>

<template>
  <div class="form-section">
    <h2 class="section-title">通知设置</h2>
    
    <div class="notification-item">
      <div class="notification-info">
        <h3>电子邮件通知</h3>
        <p>接收重要更新、订单确认和促销信息</p>
      </div>
      <div class="toggle-switch">
        <input type="checkbox" id="toggle-email" v-model="notificationSettings.email">
        <label for="toggle-email"></label>
      </div>
    </div>
    
    <div class="notification-item">
      <div class="notification-info">
        <h3>短信通知</h3>
        <p>接收旅行提醒和重要更新</p>
      </div>
      <div class="toggle-switch">
        <input type="checkbox" id="toggle-sms" v-model="notificationSettings.sms">
        <label for="toggle-sms"></label>
      </div>
    </div>
    
    <div class="notification-item">
      <div class="notification-info">
        <h3>应用推送</h3>
        <p>接收应用内推送通知</p>
      </div>
      <div class="toggle-switch">
        <input type="checkbox" id="toggle-push" v-model="notificationSettings.push">
        <label for="toggle-push"></label>
      </div>
    </div>
    
    <div class="form-actions">
      <button class="save-btn" @click="handleSaveSettings">保存设置</button>
    </div>
  </div>
</template>

<style scoped>
.form-section {
  animation: slideIn 0.6s ease-out forwards;
  opacity: 0.1;
}

@keyframes slideIn {
  0% {
    opacity: 0.1;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.section-title {
  font-size: 1.4rem;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.notification-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 15px;
  transition: all 0.3s ease;
}

.notification-item:hover {
  background-color: #f0f9f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.notification-info h3 {
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 5px;
}

.notification-info p {
  font-size: 0.9rem;
  color: #666;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ddd;
  border-radius: 24px;
  cursor: pointer;
  transition: 0.4s;
}

.toggle-switch label:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: 0.4s;
}

.toggle-switch input:checked + label {
  background-color: #00c389;
}

.toggle-switch input:checked + label:before {
  transform: translateX(26px);
}

.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 30px;
  animation: fadeUp 0.8s ease-out forwards;
  animation-delay: 0.4s;
  opacity: 0.1;
}

@keyframes fadeUp {
  0% {
    opacity: 0.1;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.save-btn {
  padding: 12px 30px;
  background-color: #00c389;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.save-btn:hover {
  background-color: #00b07b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3);
}
</style> 